<?php
session_start();
$id_user = $_SESSION["id_user"];
require_once "connexion.php";
require_once "Model/devisModel.php";
require_once "Model/userModel.php";
//Appel au singleton Connexion
$maConnexion = ConnexionSingleton::getInstance();
$maConnexion->Connect();
?>
<div id="message_suppr" style="float:left;height:25px;width:100%;"> </div>
<?php 
	$user = new userModel();
	$tab_user = $user->getUsers();
	foreach($tab_user as $key => $value)
	{
		echo "<div class='badge_utilisateur' id='".$value['id']."'>";
			echo "<div class='header_badge'>";
				echo "<div style='float:right;width:99%;text-align:right;height:35px;'>";
				if($user->getStatut($id_user) == 1)
				{
						echo "<img src='css/images/supprimer.png' id='supprimer'>";
				}
				echo "</div>";
				echo "<div class='enteteUtilisateur'>";	
					echo strtoupper($value["nom"])." ".ucfirst($value["prenom"]);
				echo "</div>";
			echo "</div>";
			echo "<div class='content_badge'>";
				echo "<div class='photoUtilisateur'>";
					echo "<img src='css/images/photo.gif'/>";
				echo "</div>";
				echo "<div class='infosUtilisateur'>";
					echo $value["mail"];
					echo "<br/>";
					echo "<img src='css/images/code_barre.gif'/>";
				echo "</div>";
			echo "</div>";
			echo "<div class='footer_badge'>";
				echo $value["statut"];
			echo "</div>";
		echo "</div>";
	}
?>
<script>
	$('#supprimer').live("click",function()
	{
		if (confirm("Etes vous sur de vouloir supprimer l'enregistrement ?"))
		{
			var id = $(this).parent().parent().parent().attr('id');
			var data = 'id_user='+id;
			var parent = $(this).parent().parent().parent();
			
			$.ajax(
			{
				   type: "POST",
				   url: "Controller/userController.php?suppression",
				   data: data,
				   cache: false,

				   success: function(msg)
				   {
						$('#message_suppr').html(msg);
						parent.fadeOut('slow', function() {$(this).remove();});
				   }
			 });
		}
	});
</script>